<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/mui.min.css">
		<style>
			
		</style>
	</head>

	<body>
		
		<div class="mui-content">
			<div id="slider" class="mui-slider mui-fullscreen">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a class="mui-control-item mui-active" href="#item1mobile" data-wid="home-subpage-1.html">
							推荐
						</a>
						<a class="mui-control-item" href="#item2mobile" data-wid="home-subpage-2.html">
							食疗
						</a>
						<a class="mui-control-item" href="#item3mobile" data-wid="home-subpage-3.html">
							中药
						</a>
						<a class="mui-control-item" href="#item4mobile" data-wid="home-subpage-4.html">
							西药
						</a>
						<a class="mui-control-item" href="#item5mobile" data-wid="home-subpage-5.html">
							中西混合
						</a>
						<!--<a class="mui-control-item" href="#item6mobile" data-wid="home-subpage-6.html">
							科技
						</a>-->
					</div>
				</div>

			</div>
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/webviewGroup.js" type="text/javascript" charset="utf-8"></script>
		<script>
			mui.init();
			
			mui.plusReady(function() {
				var group = new webviewGroup("home.html", {
					items: [{
						id: "home-subpage-1.html",
						url: "home-subpage-1.html",
						extras: {}
					}, {
						id: "home-subpage-2.html",
						url: "home-subpage-2.html",
						extras: {}
					}, {
						id: "home-subpage-3.html",
						url: "home-subpage-3.html",
						extras: {}
					}, {
						id: "home-subpage-4.html",
						url: "home-subpage-4.html",
						extras: {}
					}, {
						id: "home-subpage-5.html",
						url: "home-subpage-5.html",
						extras: {}
					}],
					onChange: function(obj) {
						var c = document.querySelector(".mui-control-item.mui-active");
						if(c) {
							c.classList.remove("mui-active");
						}
						document.querySelector(".mui-scroll .mui-control-item:nth-child(" + (parseInt(obj.index) + 1) + ")").classList.add("mui-active");
					}
				});
				mui(".mui-scroll").on("tap", ".mui-control-item", function(e) {
					var wid = this.getAttribute("data-wid");
					group.switchTab(wid);
				});
				
		     	// 监听滑动事件
//		     	var changeTab = function(curTab, targetTab, targetTabTitle){
//		      		var curWebview = plus.webview.currentWebview();		     		
//		      		var targetWebview = plus.webview.getWebviewById(targetTab);
//		      		targetWebview.show();
//		      		curWebview.hide();
//					// 获取当前页面的父页面（创建它的页面）
//					var index = curWebview.opener();
//		      		// 在父页面执行JS，激活父页面中对应选择卡，修改标题
//					index.evalJS("document.getElementById('home.html').classList.remove('mui-active');document.getElementById('chat.html').classList.add('mui-active');document.getElementById('title').innerHTML='" + targetTabTitle + "';");
//		     	};
		      	document.querySelector('body').addEventListener('swipeleft',function(e){
	      			if ( JSON.stringify(app.getState()) == '{}' ){
		      			changeTab('home.html','login.html','登录');
		      		}
	      			else{
		      			changeTab('home.html','chat.html','交流');	      				
	      			}
		      	});


			});
			mui.back = function() {
				var _self = plus.webview.currentWebview();
				_self.close("auto");
			}
		</script>
	</body>

</html>